<p>Java 8 introduced <code>ThreadLocal.withInitial</code> which is a simpler alternative to creating an anonymous inner class to initialise a
<code>ThreadLocal</code> instance.</p>
<p>This rule raises an issue when a <code>ThreadLocal</code> anonymous inner class can be replaced by a call to
<code>ThreadLocal.withInitial</code>.</p>
<h2>Noncompliant Code Example</h2>
<pre>
ThreadLocal&lt;List&lt;String&gt;&gt; myThreadLocal =
    new ThreadLocal&lt;List&lt;String&gt;&gt;() { // Noncompliant
        @Override
        protected List&lt;String&gt; initialValue() {
            return new ArrayList&lt;String&gt;();
        }
    };
</pre>
<h2>Compliant Solution</h2>
<pre>
ThreadLocal&lt;List&lt;String&gt;&gt; myThreadLocal = ThreadLocal.withInitial(ArrayList::new);
</pre>

